package com.diet.system.service.impl;

import com.diet.common.utils.DateUtils;
import com.diet.system.domain.DietUser;
import com.diet.system.mapper.DietUserMapper;
import com.diet.system.service.IDietUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 饮食用户Service业务层处理
 */
@Service
public class DietUserServiceImpl implements IDietUserService 
{
    @Autowired
    private DietUserMapper dietUserMapper;

    /**
     * 查询饮食用户
     * 
     * @param userId 饮食用户主键
     * @return 饮食用户
     */
    @Override
    public DietUser selectDietUserByUserId(String userId)
    {
        return dietUserMapper.selectDietUserByUserId(userId);
    }

    /**
     * 查询饮食用户列表
     * 
     * @param dietUser 饮食用户
     * @return 饮食用户
     */
    @Override
    public List<DietUser> selectDietUserList(DietUser dietUser)
    {
        return dietUserMapper.selectDietUserList(dietUser);
    }

    /**
     * 新增饮食用户
     * 
     * @param dietUser 饮食用户
     * @return 结果
     */
    @Override
    public int insertDietUser(DietUser dietUser)
    {
        dietUser.setCreateTime(DateUtils.getNowDate());
        return dietUserMapper.insertDietUser(dietUser);
    }

    /**
     * 修改饮食用户
     * 
     * @param dietUser 饮食用户
     * @return 结果
     */
    @Override
    public int updateDietUser(DietUser dietUser)
    {
        dietUser.setUpdateTime(DateUtils.getNowDate());
        return dietUserMapper.updateDietUser(dietUser);
    }

    /**
     * 批量删除饮食用户
     * 
     * @param userIds 需要删除的饮食用户主键
     * @return 结果
     */
    @Override
    public int deleteDietUserByUserIds(String[] userIds)
    {
        return dietUserMapper.deleteDietUserByUserIds(userIds);
    }

    /**
     * 删除饮食用户信息
     * 
     * @param userId 饮食用户主键
     * @return 结果
     */
    @Override
    public int deleteDietUserByUserId(String userId)
    {
        return dietUserMapper.deleteDietUserByUserId(userId);
    }

    /**
     * 获取用户性别分布统计
     * 
     * @return 统计结果
     */
    @Override
    public List<Map<String, Object>> selectUserGenderDistribution()
    {
        return dietUserMapper.selectUserGenderDistribution();
    }

    /**
     * 获取用户年龄分布统计
     * 
     * @return 统计结果
     */
    @Override
    public List<Map<String, Object>> selectUserAgeDistribution()
    {
        return dietUserMapper.selectUserAgeDistribution();
    }

    /**
     * 获取昨日登录用户数
     * 
     * @return 用户数
     */
    @Override
    public int selectYesterdayLoginUsers()
    {
        return dietUserMapper.selectYesterdayLoginUsers();
    }
}